package core;

import parsing.ParsingTools;


public class Continent implements Comparable<Continent> {

	// members
	String continentName;
	int continentId;

	public Continent(String continentName, String continentId) {
		this.continentName = continentName;
		int id =ParsingTools.GetCountryIDFromCode(continentId);
		this.continentId = id;
	}

	// Construct For Simulation
	public Continent(String continentName, int continentId) {
		this.continentName = continentName;
		this.continentId = continentId;
	}
	
	public void setContinentId(int continentId) {
		this.continentId = continentId;
	}
	
	public int getContinentId() {
		return continentId;
	}
	
	public String getContinentName(){
		return continentName;
	}
	
	public void setContinentName(String continentName){
		this.continentName=continentName;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (!(obj instanceof Continent)) {
			return false;
		}
		Continent other = (Continent) obj;
		if ((this.continentId == other.continentId)
				&& (this.continentName.equals(other.continentName))) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		int hash = 17;
		hash = 37
				* hash
				+ (this.continentName != null ? this.continentName.hashCode()
						: 0);
		hash = 37 * hash + this.continentId;
		return hash;
	}

	@Override
	public int compareTo(Continent that) {
		int nameDiff = this.continentName
				.compareToIgnoreCase(that.continentName);
		long result = nameDiff;
		if (nameDiff == 0) {/* Debug to check if the id returns correct */
			result = this.continentId - that.continentId;
		}
		return Long.signum(result);
	}
}
